package com.yunshan.order;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yunshan.common.annotation.Log;
import com.yunshan.common.core.controller.BaseController;
import com.yunshan.common.core.domain.AjaxResult;
import com.yunshan.common.enums.BusinessType;
import com.yunshan.order.domain.OrderReserveNotice;
import com.yunshan.order.service.IOrderReserveNoticeService;
import com.yunshan.common.utils.poi.ExcelUtil;
import com.yunshan.common.core.page.TableDataInfo;

/**
 * 预约通知Controller
 * 
 * @author yunshan
 * @date 2025-01-17
 */
@Api(tags = "预约通知")
@RestController
@RequestMapping("/order/reserve")
public class OrderReserveNoticeController extends BaseController
{
    @Autowired
    private IOrderReserveNoticeService orderReserveNoticeService;

    /**
     * 查询预约通知列表
     */
    @ApiOperation("查询预约通知列表")
    @PreAuthorize("@ss.hasPermi('order:reserve:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderReserveNotice orderReserveNotice)
    {
        startPage();
        List<OrderReserveNotice> list = orderReserveNoticeService.selectOrderReserveNoticeList(orderReserveNotice);
        return getDataTable(list);
    }

    /**
     * 导出预约通知列表
     */
    @ApiOperation("导出预约通知列表")
    @PreAuthorize("@ss.hasPermi('order:reserve:export')")
    @Log(title = "预约通知", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderReserveNotice orderReserveNotice)
    {
        List<OrderReserveNotice> list = orderReserveNoticeService.selectOrderReserveNoticeList(orderReserveNotice);
        ExcelUtil<OrderReserveNotice> util = new ExcelUtil<OrderReserveNotice>(OrderReserveNotice.class);
        util.exportExcel(response, list, "预约通知数据");
    }

    /**
     * 获取预约通知详细信息
     */
    @ApiOperation("获取预约通知详细信息")
    @PreAuthorize("@ss.hasPermi('order:reserve:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(orderReserveNoticeService.selectOrderReserveNoticeById(id));
    }

    /**
     * 新增预约通知
     */
    @ApiOperation("新增预约通知")
    @PreAuthorize("@ss.hasPermi('order:reserve:add')")
    @Log(title = "预约通知", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderReserveNotice orderReserveNotice)
    {
        return toAjax(orderReserveNoticeService.insertOrderReserveNotice(orderReserveNotice));
    }

    /**
     * 扫码核销
     */
    @ApiOperation("扫码核销")
    @PreAuthorize("@ss.hasPermi('order:reserve:edit')")
    @Log(title = "扫码核销", businessType = BusinessType.OTHER)
    @PostMapping("/verify")
    public AjaxResult verify(@RequestBody OrderReserveNotice orderReserveNotice)
    {
        return toAjax(orderReserveNoticeService.verifyOrderReserveNotice(orderReserveNotice));
    }


    /**
     * 取消预约
     */
    @ApiOperation("取消预约")
    @PreAuthorize("@ss.hasPermi('order:reserve:edit')")
    @Log(title = "取消预约", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult cancel(@RequestBody OrderReserveNotice orderReserveNotice)
    {
        orderReserveNotice.setStatus(2);
        return toAjax(orderReserveNoticeService.updateOrderReserveNotice(orderReserveNotice));
    }


    /**
     * 删除预约通知
     */
    @ApiOperation("删除预约通知")
    @PreAuthorize("@ss.hasPermi('order:reserve:remove')")
    @Log(title = "预约通知", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(orderReserveNoticeService.deleteOrderReserveNoticeByIds(ids));
    }
}
